import 'package:flutter/material.dart';
import 'package:flutter_appgetwe/page/addvideo/add_video.dart';
import 'package:flutter_appgetwe/page/home/home_index_pro_two.dart';
import 'package:flutter_appgetwe/page/message/message_index.dart';
import 'package:flutter_appgetwe/page/my/my_index_pro.dart';
import 'package:flutter_appgetwe/page/search/search_index.dart';
import 'package:flutter_appgetwe/provider/LoginProvider.dart';
import 'package:provider/provider.dart';

import '../page/detailvideo/detaill_video_index.dart';

class TkVideo {
  late int id;
  late String name;
  late String desc;
  late String imageUrl;
  late String videoUrl;
  late int dFlag;
  late String createTime;
  late String updateTime;

  TkVideo.name(this.id, this.name, this.desc, this.imageUrl, this.videoUrl,
      this.dFlag, this.createTime, this.updateTime);
}

class TabbarView extends StatefulWidget {
  List<Widget> tabsbottom = [
    DetailVideoIndex(),
    SearchIndex(),
    AddVideo(),
    MessageIndex(),
    MyIndexPro()
  ];

  @override
  _TabbarViewState createState() => _TabbarViewState();
}

class _TabbarViewState extends State<TabbarView> {
  List<Map> mapList = [
    {"id": 1, "name": "首页"},
    {"id": 2, "name": "朋友"},
    {"id": 3, "name": "+"},
    {"id": 4, "name": "消息"},
    {"id": 5, "name": "我"},
  ];

  int _index = 3;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    print("打印获取到的状态");
    print(context.read<LoginProvider>().getUserName());
    print(context.read<LoginProvider>().getIsLogin());
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text("底部选项卡"),
      //   centerTitle: true,
      // ),
      // bottomNavigationBar: BottomNavigationBar(
      //   //backgroundColor: Colors.cyan,
      //   type: BottomNavigationBarType.fixed,
      //   items: [
      //     BottomNavigationBarItem(
      //       label: "Home",
      //       icon: Icon(Icons.home),
      //     ),
      //     BottomNavigationBarItem(
      //       label: "Search",
      //       icon: Icon(Icons.search),
      //     ),
      //     BottomNavigationBarItem(
      //       label: "",
      //       icon: CoustomIcon(),
      //     ),
      //     BottomNavigationBarItem(
      //       label: "List",
      //       icon: Icon(Icons.list),
      //     ),
      //     BottomNavigationBarItem(
      //       label: "Admin",
      //       icon: Icon(Icons.account_circle_rounded),
      //     ),
      //   ],
      //   currentIndex: _index,
      //   selectedItemColor: Colors.red,
      //   unselectedItemColor: Colors.white,
      //   onTap: (v) {
      //     print(v);
      //     setState(() {
      //       _index = v;
      //     });
      //   },
      // ),
      body: Stack(children: [
        widget.tabsbottom[_index],
        Positioned(
            bottom: 0,
            child: Container(
              alignment: Alignment.center,
              width: MediaQuery.of(context).size.width,
              height: 50,
              color: _index == 3
                  ? Colors.white
                  : _index == 4
                      ? Colors.white
                      : Color.fromRGBO(1, 1, 1, 0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: mapList
                    .map(
                      (e) => InkWell(
                        onTap: () {
                          setState(() {
                            _index = e["id"] - 1;
                          });
                        },
                        child: Container(
                          alignment: Alignment.center,
                          width: e["id"] == 3 ? 40 : 70,
                          height: e["id"] == 3 ? 25 : 50,
                          decoration: BoxDecoration(
                            //color: e["id"] == 3 ?Colors.white:Color.fromRGBO(1, 1, 1, 0),
                            border: e["id"] == 3? Border.all(width: 2,color:_index == 0 ? Colors.white:_index == 1?Colors.white:_index == 3?Colors.black:_index == 4 ?Colors.black:Colors.white):Border.all(width: 0,color: Color.fromRGBO(1, 1, 1,0)),
                            borderRadius: e["id"] == 3
                                ? BorderRadius.circular(5)
                                : BorderRadius.circular(0),
                          ),
                          child:
                          _index == 3?Text(e["name"].toString(),style: TextStyle(
                              fontSize: e["id"] == 3 ? 20 : 16,
                              color: e["id"] - 1 == 3
                                  ? Colors.black:e["id"]-1 ==2 ?Colors.black: Colors.black26,
                              fontWeight: FontWeight.w600),):
                          _index == 4?Text(e["name"].toString(),style: TextStyle(
                              fontSize: e["id"] == 3 ? 20 : 16,
                              color: e["id"] - 1 == 4
                                  ? Colors.black:e["id"]-1 ==2 ?Colors.black: Colors.black26,
                              fontWeight: FontWeight.w600),):
                          _index == 0?Text(e["name"].toString(),style: TextStyle(
                              fontSize: e["id"] == 3 ? 20 : 16,
                              color: e["id"] - 1 == 0
                                  ? Colors.white:e["id"]  ==3 ?Colors.white: Colors.black26,
                              fontWeight: FontWeight.w600),):
                          _index == 1?Text(e["name"].toString(),style: TextStyle(
                              fontSize: e["id"] == 3 ? 20 : 16,
                              color: e["id"] - 1 == 1
                                  ? Colors.white:e["id"] ==3 ?Colors.white: Colors.black26,
                              fontWeight: FontWeight.w600),):
                          Text(e["name"].toString(),style: TextStyle(
                              fontSize: e["id"] == 2 ? 20 : 16,
                              color: e["id"] - 1 == 0
                                  ? Colors.black:e["id"] ==3 ?Colors.white: Colors.black26,
                              fontWeight: FontWeight.w600),),
                        ),
                      ),
                    )
                    .toList(),
              ),
            ))
      ]),
      // floatingActionButton: FloatingActionButton(
      //   child: Icon(Icons.widgets_rounded),
      //   onPressed: () {
      //     print("object");
      //   },
      // ),
    );
  }
}
